/*
 * @lc app=leetcode.cn id=274 lang=cpp
 *
 * [274] H 指数
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
    int hIndex(vector<int>& citations) {
        int ans = 0;
        sort(citations.begin(), citations.end());
        for(int i = 0; i < citations.size(); i++)
        {
            if(citations[citations.size() - i - 1] >= i+1)
            {
                ans = i + 1;
            }
        }
        return ans;
    }
};
// @lc code=end

